/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedBean.TX.SABM;

import entity.tx.*;
import session.TX.*;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author Randall Chia
 */
@ManagedBean(name = "categoryManagerBean")
@RequestScoped
public class StakeholderCategoryMB {
    
    @EJB
    StakeholderCategorySBRemote categorySBInterface;

    /** Creates a new instance of StakeholderCategoryMB */
    
    private List<String> categoryTypeList = new ArrayList<String>();
    
    private Category inputCategory;
    
    private String inputCategoryType;
    private String inputDescription;
    
    
    
    public StakeholderCategoryMB() {
        categoryTypeList.add("stakeholder_Food");
        categoryTypeList.add("stakeholder_PerformanceEvent");
    }
    
    
    
    //MAKE A NEW CATEGORY
    public void addNewCategory(){
        System.out.println(">>> StakeholderCategoryMB create category " + inputDescription + "   " + inputCategoryType);
        String msg = categorySBInterface.addNewCategory(inputDescription, inputCategoryType);
        System.out.println(msg);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, msg, ""));
    }
    
    //DELETE A CATEGORY
    public void removeCategory(Category c){
        System.out.println(">>> StakeholderCategoryMB remove category " + c.getDescription());
        String msg = categorySBInterface.removeCategory(c.getDescription());
        System.out.println(msg);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, msg, ""));
    }
    
    //GET ALL THE CATEGORY DESCRIPTIONS
    public List<Category> getAllCategories(){
        return categorySBInterface.getAllCategories();
    }
    
    
    
    //Get and Set Methods

    /**
     * @return the categoryList
     */
    public List<String> getCategoryTypeList() {
        return categoryTypeList;
    }

    /**
     * @param categoryList the categoryList to set
     */
    public void setCategoryTypeList(List<String> categoryTypeList) {
        this.categoryTypeList = categoryTypeList;
    }

    /**
     * @return the inputCategory
     */
    public Category getInputCategory() {
        return inputCategory;
    }

    /**
     * @param inputCategory the inputCategory to set
     */
    public void setInputCategory(Category inputCategory) {
        this.inputCategory = inputCategory;
    }

    /**
     * @return the inputCategoryType
     */
    public String getInputCategoryType() {
        return inputCategoryType;
    }

    /**
     * @param inputCategoryType the inputCategoryType to set
     */
    public void setInputCategoryType(String inputCategoryType) {
        this.inputCategoryType = inputCategoryType;
    }

    /**
     * @return the inputDescription
     */
    public String getInputDescription() {
        return inputDescription;
    }

    /**
     * @param inputDescription the inputDescription to set
     */
    public void setInputDescription(String inputDescription) {
        this.inputDescription = inputDescription;
    }
    
    
    
    
    
    
}
